package ch.areion.areionapp.engine;


import ch.areion.areionapp.core.Disconnectable;
import ioio.lib.api.exception.ConnectionLostException;

/**
 * This interface defines how to handle the engine of Areion.
 * @author IljasaRedzepi
 * @version 0.1
 */

public interface IEngine extends Disconnectable {
	
	/**
	 * With this method the Areion corrects its current angle parallel to the wall.
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void correctAngle() throws ConnectionLostException, InterruptedException;
	
	/**
	 * With this method the Areion corrects its current position parallel to the wall with a certain gap. This is a one shot correction.
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void correctPosition(int gap) throws ConnectionLostException, InterruptedException;
	
	/**
	 * With this method the Areion corrects its current position parallel to the wall with a certain gap. This method allows a more accurate position.
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void correctPosition(int gap, int number) throws ConnectionLostException, InterruptedException;
	
	/**
	 * With this method the Areion drives forward.
	 * @param speed in [mm/s] signed 16 bit
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void driveStraight(int speed) throws ConnectionLostException, InterruptedException;
	
	/**
	 * With this method the Areion stops.
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void stop() throws ConnectionLostException, InterruptedException;
	
	/**
	 * Areion drives along a wall on the right side and tries to reach or hold the gap between him and the wall.
	 * @param speed in [mm/s] signed 16 bit
	 * @param gap between wall and the middle of the robot in [mm]
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void driveAlongWall(int speed) throws ConnectionLostException, InterruptedException;
	
	public void driveAlongLine(int speed, int gap) throws ConnectionLostException, InterruptedException;
	
	/**
	 * Areion drives along a wall on the right side and tries to reach or hold the gap between him and the wall.
	 * @param speed in [mm/s] signed 16 bit
	 * @param gap between wall and the middle of the robot in [mm]
	 * @param distance to drive [mm]
	 * @throws ConnectionLostException When IOIO connection is lost.
	 * @throws InterrruptedException When thread is interrupted.
	 */
	public void driveAlongWallTimed(int speed, int time) throws ConnectionLostException, InterruptedException;
	
	public void driveAlongLineTimed(int speed, int gap, int time) throws ConnectionLostException, InterruptedException;

	public void driveLeftTicked(int speed, int ticks) throws ConnectionLostException, InterruptedException;
	
	public void driveRightTicked(int speed, int ticks) throws ConnectionLostException, InterruptedException;

	public void driveStraightTicked(int speed, int ticks)throws ConnectionLostException, InterruptedException;
	
	public void rotateLeft(int speed, int time) throws ConnectionLostException, InterruptedException;
	
	public void rotateRight(int speed, int time) throws ConnectionLostException, InterruptedException;
	
	/**
	 * Sets the speed of the Motor 1 and 2 the target ticks to reach. After which a stop occurs. This method blocks until finished.
	 * @param speed speed 16 bit signed in [mm/s]
	 * @exception ConnectionLostException
	 * @exception InterruptedException
	 */
	public void setSpeedsAndTicks(int speedM1, int speedM2, int ticks) throws ConnectionLostException, InterruptedException;
}
